$(function () {
  console.log(getSearch())
  
  $('.login').on('click', function () {
    if (!$('[name=username]').val()) {
      mui.toast('请输入用户名')
      return
    }
    if (!$('[name=password]').val()) {
      mui.toast('请输入密码')
      return

    }
    
    $.ajax({
      url: '/user/login',
      type: 'post',
      data: $('form').serialize(),
      success: function (info) {
        console.log(info)
        if (info.success) {
          var search = location.search
          console.log(search)
          if(search.indexOf('?backUrl=') === -1) {
            location.href = 'user.html'
          }else {
            location.href = search.replace('?backUrl=','')
          }
        }
        if (info.error === 403) {
          mui.toast(info.message)
        }
      }
    })


  })
})